function [score,grad] = score_lin_regression(mus, Cs, n)

if size(mus,2)~=numel(Cs)
    error('number of columns in mus and the size Cs should be the same')
end
if size(n,1)~=1
    error('n should be row vector')
end
if size(mus,1)~= size(n,2)
    error('size of each column of mus and the size of n should be the same')
end
if size(mus,2)~=1
    score = 0;
    grad = zeros(size(n))';
    for i=1:numel(Cs)
        [tmp_score, tmp_grad] = score_lin_regression(mus(:,i),Cs(i),n);
        score = score + tmp_score;
        grad  = grad + tmp_grad;
    end
    return
end

tmp = mus'*Cs{1}*mus;
n = n/(sum(n.^2)^0.5);
score = ((n*mus)^2)/tmp + 0.5*log(tmp);
grad = 2*(n*mus)*(n*Cs{1}*n')*mus/(tmp^2) + (Cs{1}*n')/tmp;

end